home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / falcon / programm.ing / nt_dsp1.lzh / NT_DSP1.MSA / SPECTRUM / ASPEC2.ASM next >
Assembly Source File  |  1992-08-07  |  25KB  |  441 lines

  1.           title  'Log-Log Audio Spectrum Analyzer'
  2. ;**************************************************************************
  3. ;*     Motorola Austin DSP Operation  June 06, 1991                       *
  4. ;*                                                                        *
  5. ;*       *  ALTHOUGH THE INFORMATION CONTAINED HEREIN,    *               *
  6. ;*       *  AS WELL AS ANY INFORMATION PROVIDED RELATIVE  *               *
  7. ;*       *  THERETO, HAS BEEN CAREFULLY REVIEWED AND IS   *               *
  8. ;*       *  BELIEVED ACCURATE, MOTOROLA ASSUMES NO        *               *
  9. ;*       *  LIABILITY ARISING OUT OF ITS APPLICATION OR   *               *
  10. ;*       *  USE, NEITHER DOES IT CONVEY ANY LICENSE UNDER *               *
  11. ;*       *  ITS PATENT RIGHTS NOR THE RIGHTS OF OTHERS.   *               *
  12. ;*                                                                        *
  13. ;*  This program originally available on the Motorola DSP bulletin board. *
  14. ;*  It is provided under a DISCLAMER OF WARRANTY available from           *
  15. ;*  Motorola DSP Operation, 6501 Wm. Cannon Drive W., Austin, Tx., 78735. *
  16. ;*                                                                        *
  17.  
  18. ;**********************************************************************
  19. ; Real time log-log scale spectrum analyzer program                   *
  20. ;**********************************************************************
  21. ;   Source file name :        aspec2.asm
  22. ;         0.0     Jan.  3 1990
  23. ;         1.0     Mar. 23 1990 
  24. ;         1.1     Jul. 26 1990      - speed-up for windowing
  25. ;         1.2     Oct. 18 1990      - collapsed into single Goertzel sub. 
  26. ;         2.0     Feb. 28 1990      - added interrupt driven input
  27. ;
  28. ; -This program will take in N samples from the DSP56ADC16 sigma delta 
  29. ;  converter and perform a DFT routine using Goertzel method.
  30. ; -The receive input buffer is filled under interrupt control
  31. ; -When the computations for the spectrum are completed, the input
  32. ;  buffer (RXBUFF) is copied into D_IN and a new set of computations
  33. ;  begin. During this time, RXBUFF continues to get new data samples,but
  34. ;  this does not corrupt the buffer move because the oldeset sample is
  35. ;  copied before the next input sample overwrites it. All other samples
  36. ;  will have adequate time to be copied before changed by the input.
  37. ; -Results are sent to a PCM-56 DAC
  38. ; -The spectrum is viewed on a scope.
  39. ;
  40. ; Notes: 60, 0, -60, and -120 dB output reference levels
  41. ;    DSP56001 REV C is required for SSI mixed length frame syncs
  42. ;    Requires ADC16EVB modified for async SSI
  43. ;-----------------------------------------------------------------------------
  44.           page   255,66,3,3,5
  45.           opt    nomd,nomex,nocex
  46.  
  47. BOOTMODE  equ    ROM                        ;1 == boot from ROM
  48. start     equ    $40                        ;location of main routine
  49. ROMBASE   equ    $4000                      ;load address of ROM - $8000
  50. POINTS    equ    2048                       ;number of input data points($800)
  51. D_IN      equ    0                          ;location of input data table
  52. D_OUT     equ    POINTS                     ;location of output display table
  53. COS_TABL  equ    POINTS/2                   ;sine and cosine table 
  54. SIN_TABL  equ    POINTS/2+POINTS/4
  55. BUF1      equ    POINTS                     ;location for 1024 data buffer
  56. BUF2      equ    POINTS+POINTS/2            ;location for 512  data buffer
  57. BUF3      equ    POINTS+POINTS/2+POINTS/4   ;location for 256  data buffer
  58. WIN_TABL  equ    0                          ;location of Blackman_Harris window
  59. RXBUFF    equ    2*POINTS                   ;location of input data
  60.  
  61. ;----------------------------------------------------------------------------
  62. ;            ***** MEMORY MAP *****
  63. ;         -X-                       -Y-
  64. ;                                   $1800 --------
  65. ;                                   $1000 RXBUFFER   
  66. ;        $0F00 -----                  .
  67. ;        $0E00 BUF3                   .         
  68. ;        $0C00 BUF2                   .         
  69. ;                                   $0A00  Polynomial Coefficients
  70. ;        $0800 BUF1                 $0800  D_OUT
  71. ;                                   $0600  SINE   Table
  72. ;                                   $0400  COSINE Table
  73. ;        $0000 D_IN                 $0000  Window Table
  74. ;----------------------------------------------------------------------------
  75.  
  76. ;    MOTOROLA DSP56001 Internal I/O Addresses
  77.  
  78. m_ipr     equ    $ffff       ;Interrupt Prioroty Register
  79. m_bcr     equ    $fffe       ;Bus Control Register
  80. m_sccr    equ    $fff2       ;SCI Clock Control Register
  81. m_scr     equ    $fff0       ;SCI Control Register
  82. m_tx      equ    $ffef       ;SSI Tx Data Register
  83. m_rx      equ    $ffef       ;SSI Rx Data Register
  84. m_sr      equ    $ffee       ;SSI Status  Register
  85. m_crb     equ    $ffed       ;SSI Control Register A
  86. m_cra     equ    $ffec       ;SSI Control Register B
  87. m_bdr     equ    $ffe4       ;Port-B Data Register
  88. m_bddr    equ    $ffe2       ;Port-B Data Direction Register
  89. m_pcc     equ    $ffe1       ;Port-C Control register
  90.  
  91.  
  92.           IF     BOOTMODE==1                ;*** if booting from ROM ***
  93.           MSG    'Building Code for ROM Boot'
  94. ;--------------------------------------------------------------------------
  95. ;       RESET vector
  96. ;       first, move the tables from ROM into data memory
  97. ;--------------------------------------------------------------------------
  98.           org    p:0,p:ROMBASE         ;RUN @ P:$0000, LOAD from P:$C000
  99. GO        move   #$C000+(3*WIN_LOC),r0 ;points to start of tables in ROM
  100.           move   #0,r5                 ;destination for tables in Y:
  101.           do     #Tab_Len,_table       ;load all tables..., length <= $FFF
  102.           do     #3,_word              ;3 bytes per word...
  103.           move   P:(R0)+,A2            ;get a byte from P:ROM
  104.           rep    #8                    ;shift it into position...
  105.           asr    A                     ;...to form a 24-bit word
  106. _word                                  
  107.           move   A1,y:(r5)+            ;move complete word into y:memory
  108. _table
  109.           jmp    <SPEC
  110.  
  111.           ELSE
  112.           MSG    'Building Code for ADM execution'
  113.           org    p:$0C
  114.  
  115.           ENDIF
  116. ;-------------------------------------
  117. ;       SSI RX Interrupt vector
  118. ;-------------------------------------          
  119.                                        ; *** org    p:$000C,P: ***
  120.           movep  x:m_tx,y:(r1)+        ;input from ADC16
  121.           nop
  122.           movep  x:m_tx,y:(r1)+        ;input from ADC16
  123.           nop
  124. ;-------------------------------------
  125. ;       SSI TX Interrupt vector
  126. ;-------------------------------------          
  127.           movep  y:(r6)+,x:m_rx        ;output to D/A PCM-56
  128.           nop
  129.           movep  y:(r6)+,x:m_rx        ;output to D/A PCM-56
  130.           nop
  131.  
  132.           DUP    $2C                   ;fill unused vectors w/ nops
  133.           nop
  134.           ENDM
  135.  
  136. ;-------------------------------------
  137. ;  Initialization
  138. ;-------------------------------------
  139.                                        ;this code s/b @ P:$0040
  140. SPEC      movep  #0,x:m_bcr            ;set bcr to zero
  141.           movec  #0,sp                 ;init stack pointer
  142.           movec  #0,sr                 ;clear loop flag
  143.           movep  #0,x:m_pcc            ;zero PCC to cycle it, reset peripherals
  144. ;-----------------------------------------------------------------------
  145. ; set the SCI to provide ADC16 clock
  146. ;-----------------------------------------------------------------------
  147.           movep  #$1000,x:m_sccr       ;SCCR pattern for sclk= x16 baud rate
  148.           movep  #$2,x:m_scr           ;SCR pattern for sclk= x16 baud rate
  149. ;-----------------------------------------------------------------------
  150. ; set the SSI to recieve ADC16's output 
  151. ; and to transmit to the PCM56 using asynchronous, normal mode. 
  152. ;-----------------------------------------------------------------------
  153.           movep  #$4107,x:m_cra        ;CRA pattern for word length=16 bits